<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <el-form label-width="150px" style="width: 80%">
        <el-form-item  label="国家" prop="country">
            <el-input v-model="FormData.country"></el-input>
        </el-form-item >
        <el-form-item
                label="省份"
                prop="province">
            <el-input v-model="FormData.province"></el-input>
        </el-form-item >
        <el-form-item
                label="城市"
                prop="city">
            <el-input v-model="FormData.city"></el-input>
        </el-form-item >
        <el-form-item
                label="仓库编码"
                prop="whcode">
            <el-input v-model="FormData.whcode"></el-input>
        </el-form-item >
        <el-form-item
                label="仓库名称"
                prop="whname">
            <el-input v-model="FormData.whname"></el-input>
        </el-form-item >
        <el-form-item
                label="店铺编码"
                prop="shopcode">
            <el-input v-model="FormData.shopcode"></el-input>
        </el-form-item >
        <el-form-item
                label="店铺名称"
                prop="shopname">
            <el-input v-model="FormData.shopname"></el-input>
        </el-form-item >
        <el-form-item
                label="客户编码"
                prop="customercode">
            <el-input v-model="FormData.customercode"></el-input>
        </el-form-item >
        <el-form-item
                label="客户名称"
                prop="customername">
            <el-input v-model="FormData.customername"></el-input>
        </el-form-item >
        <el-form-item style="text-align: right">
            <el-button type="success" round v-on:click="save">保存</el-button>
        </el-form-item>
    </el-form>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        created(){
            let there = this;
            axios({
                method: 'get',
                url: '/config/get'
            }).then(function (res) {
                if(res.data.data.userConfig != null){
                    there.FormData = res.data.data.userConfig;
                }
               console.log(res.data.data.userConfig);
            }).catch(function (err) {
                    console.log(err);
                });
        },
        mounted(){
            //this.timer = setInterval(this.fleshList, 1000);
        },
        beforeDestroy() {
            clearInterval(this.timer);
        },
        data() {
            return {
                FormData:{},
                showForm:false,
                timer:''
            }
        },
        methods: {
            save(){
                let there = this;
                axios({
                    method: 'post',
                    url: '/config/save',
                    data:there.FormData
                }).then(function (res) {
                    console.log(there.FormData);
                    there.fleshList();
                }).catch(function (err) {
                    console.log(err);
                });
            },
            fleshList(){
                let there = this;
                axios({
                    method: 'get',
                    url: '/config/get'
                }).then(function (res) {
                    there.FormData = res.data.data.userConfig;
                    console.log(there.FormData);
                }).catch(function (err) {
                    console.log(err);
                });
            },
        },
    })
</script>
</html>